<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改流程定义')"/>
    <th:block th:include="include :: footer"/>
    <th:block th:include="include :: jasny-bootstrap-css"/>
    <th:block th:include="include :: jasny-bootstrap-js"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-bpmnInfo-edit">
        <input type="hidden" name="path" id="bpmnInfoPath">
        <div class="form-group">
            <label class="col-sm-3 control-label"></label>
            <div class="fileinput fileinput-new" id="fileinput" data-provides="fileinput">
                <span class="btn btn-outline-secondary btn-file">
                    <span class="fileinput-new btn btn-primary">流程文件部署</span>
                    <input id="bpmnInfoinition" type="file" name="file">
                </span>
                <span class="fileinput-filename"></span>
                <a href="#" class="close fileinput-exists" data-dismiss="fileinput" style="float: none">&times;</a>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">流程类型：</label>
            <div class="col-sm-8">
                <select name="bpmnType" class="form-control m-b" th:with="type=${@dict.getType('bus_audit_type')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">备注信息：</label>
            <div class="col-sm-8">
                <textarea name="info" class="form-control"></textarea>
            </div>
        </div>
    </form>
</div>


<script th:inline="javascript">
    var prefix = ctx + "business/bpmnInfo";
    /*1监听按钮内容改变事件*/
    $(".fileinput").on("change.bs.fileinput",function (ele) {
        let file = new FormData;
        file.append("file",$("#bpmnInfoinition")[0].files[0]);
        if (!file){
            $.modal.alertError("请选择需要的上传流程文件");
            return ;
        }
        $.ajax({
            type : "post",
            url : prefix + "/upload",
            data : file,
            //数据不需要编码
            processData : false,
            //数据对象不需要转换成键值对格式
            contentType : false,
            success : function(result){
                console.log(result);
                if (result.code == web_status.SUCCESS){
                    $("#bpmnInfoPath").val(result.data);
                }else {
                    $.modal.alertError(result.msg);
                    $('#fileinput').fileinput("clear");     // 重置
                }

            }
        });
    });


    $("#form-bpmnInfo-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/deploy", $('#form-bpmnInfo-edit').serialize());
        }
    }

</script>
</body>
</html>